package com.sirap.spring.boot.demo.sword;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.sirap.basic.domain.MexItem;

public class CarTypeItem extends MexItem {

	private static final long serialVersionUID = 1L;
	private String carplate;	//E
	private String cartype;

	public static Pattern PAT = Pattern.compile("[^a-z0-9][a-z][a-z\\d]{5}", Pattern.CASE_INSENSITIVE);
	
	public String getCarplate() {
		return carplate;
	}

	public void setCarplate(String carplate) {
		this.carplate = carplate;
	}

	public String getCartype() {
		return cartype;
	}

	public void setCartype(String cartype) {
		this.cartype = cartype;
	}

	//00809059-X	巴马县地方税务局	行政单位	一般执法执勤用车	特殊业务用车（行政执法）	北京三菱欧蓝德2.4越野车	越野车	桂M60673
	public boolean parse(List items) {
		if(items.size() < 8) {
			return false;
		}
		
		String plate = items.get(7) + "";
		Matcher ma = PAT.matcher(plate);
		if(!ma.matches()) {
			return false;
		}
		
		carplate = plate;
		cartype = items.get(5) + "";
		
		return true;
	}

	@Override
	public String toString() {
		return "CarTypeItem [carplate=" + carplate + ", cartype=" + cartype + "]";
	}
}
